package com.simpleplayer.services;

import android.util.Log;

public class LogUtil {
    private static final String Label = "xinyue-";

    public static final int Verbose = 0;
    public static final int DEBUG = 1;
    public static final int INFO = 2;
    public static final int WARNING = 3;
    public static final int ERROR = 4;
    public static final int MINLEVEL = Verbose;
    public static final int MAXLEVEL = ERROR;

    private static int LEVEL = MAXLEVEL;

    public static void setDebugLevel(int level) {
        if (level > MAXLEVEL || level < MINLEVEL) return;

        LEVEL = level;
    }

    public static int getDebugLevel() {
        return LEVEL;
    }

    public static void v(String TAG, String logInfo) {
        if (LEVEL > DEBUG) return;

        Log.v(Label + TAG, logInfo);
    }

    public static void v(String TAG, String logInfo, Throwable cause) {
        if (LEVEL > DEBUG) return;

        Log.v(Label + TAG, logInfo, cause);
    }

    public static void d(String TAG, String logInfo) {
        if (LEVEL > DEBUG) return;

        Log.d(Label + TAG, logInfo);
    }

    public static void d(String TAG, String logInfo, Throwable cause) {
        if (LEVEL > DEBUG) return;

        Log.d(Label + TAG, logInfo, cause);
    }

    public static void i(String TAG, String logInfo) {
        if (LEVEL > INFO) return;

        Log.i(Label + TAG, logInfo);
    }

    public static void i(String TAG, String logInfo, Throwable cause) {
        if (LEVEL > INFO) return;

        Log.i(Label + TAG, logInfo, cause);
    }

    public static void w(String TAG, String logInfo) {
        if (LEVEL > WARNING) return;

        Log.w(Label + TAG, logInfo);
    }

    public static void w(String TAG, String logInfo, Throwable cause) {
        if (LEVEL > WARNING) return;

        Log.w(Label + TAG, logInfo, cause);
    }

    public static void e(String TAG, String logInfo) {
        Log.e(TAG, logInfo);
    }

    public static void e(String TAG, String logInfo, Throwable cause) {
        Log.e(Label + TAG, logInfo, cause);
    }
}
